package cn.wizzer.app.web.modules.controllers.platform.user;

import cn.wizzer.app.user.modules.services.UserFeedbackService;
import cn.wizzer.framework.util.Result;
import com.alibaba.dubbo.config.annotation.Reference;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;

/**
 * 后台用户反馈管理
 */
@IocBean
@At("/platform/user/feedback")
public class UserFeedbackController {
    @Inject
    @Reference
    private UserFeedbackService userFeedBackService;

    @At("/")
    @Ok("beetl:/platform/user/feedback/index.html")
    @RequiresPermissions("user.feedback.list")
    public void index() {

    }

    /**
     * 反馈信息列表
     *
     * @param searchKeyword
     * @param searchDate
     * @param pageNumber
     * @param pageSize
     * @return
     */
    @At
    @Ok("json:full")
    @RequiresPermissions("user.feedback.list")
    public Object data(@Param("searchKeyword") String searchKeyword,
                       @Param("searchDate") String[] searchDate,
                       @Param("pageNumber") int pageNumber,
                       @Param("pageSize") int pageSize) {
        return Result.success(userFeedBackService.listPage(pageNumber, pageSize, searchKeyword, searchDate));
    }


    /**
     * 删除信息
     *
     * @param id String
     * @return Object
     */
    @At("/delete/?")
    @Ok("json")
    @RequiresPermissions("user.feedback.delete")
    public Object delete(String id) {
        userFeedBackService.delete(id);
        return Result.success();
    }
}
